<extend name="Public/common" />
<block name="body">
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>区域管理</h3>
      <ul class="tab-base">
        	<li><a href="{:U('index')}"><span>列表</span></a></li>
	        <li><a href="JavaScript:void(0);" class="current"><span>新增</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="form1" method="post" name="form1">
    <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="area_name">区域名称:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="area_name" id="area_name" class="txt"></td>
          <td class="vatop tips"></td>
        </tr>
         <tr>
          <td colspan="2" class="required"><label for="area_content">备注说明:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><textarea name="area_content" rows="6" class="tarea" id="area_content"></textarea></td>
          <td class="vatop tips"><span class="vatop rowform">简单的说明，防止备忘</span></td>
        </tr> 
        <tr>
          <td colspan="2" class="required"><label>楼宇配置:</label></td>
        </tr>
        <tr class="noborder">
          <td colspan="2">
<div id="brand_list_dialog" class="brand_list_dialog">
    <dd>
      <h4 class="dialog-handle-title">已选择楼宇</h4>
          <div class="s-tips"><i></i>小提示：单击楼宇选中，双击已选择的可以删除。提交后生效。</div>
      <ul class="brands dialog-brandslist-s1">
      </ul>
    </dd>
    <h4 class="dialog-handle-title">楼宇列表</h4>
    <div class="dialog-show-box">
    <table class="tb-type1 noborder search">
      <tbody>
        <tr>
          <th><label for="recommend_brand_name">楼宇名称</label></th>
          <td><input type="text" value="" name="recommend_brand_name" id="recommend_brand_name" class="txt">
		        <a href="JavaScript:void(0);" onclick="get_recommend_brand();" class="btn-search " title="查询"></a>
          	</td>
        </tr>
      </tbody>
    </table>
    <div id="show_brand_list"></div></div>
</div>
          
          </td>
        </tr>   
      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="15" ><a href="JavaScript:void(0);" class="btn" id="submit"><span>提交</span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script src="__JS__/jquery.ajaxContent.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#submit").click(function(){
	    if($("#form1").valid()){
	     $("#form1").submit();
		}
	});

	$("#form1").validate({
		errorPlacement: function(error, element){
			error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        rules : {
        	area_name : {
                required : true
            }
        },
        messages : {
        	area_name : {
                required : '区域名称必须填写'
            }
        }
	});	
});

function get_input(n,id) {
	return '<input type="hidden" name="'+n+'[]" value="'+id+'">';
}
function select_brand(brand_id) {
	if($("img[select_brand_id='"+brand_id+"']").size()>0) return;//避免重复
	if($("img[select_brand_id]").size()>=9999) return;
	var obj = $("img[brand_id='"+brand_id+"']");
	var text_append = '';
	var brand_pic = obj.attr("src");
	var brand_id = obj.attr("brand_id");
	var brand_name = obj.attr("title");
	text_append += '<div class="brands-pic"><span class="ac-ico" onclick="del_brand('+brand_id+');"></span>';
	text_append += '<span class="thumb size-88x29">';
	text_append += '<i></i>';
	text_append += '<img ondblclick="del_brand('+brand_id+');" select_brand_id="'+brand_id+'" src="'+brand_pic+'" onload="javascript:DrawImage(this,68,34);" />';
	text_append += '</span></div>';
	text_append += '<div class="brands-name">';
	text_append += brand_name+'</div>';
	text_append += get_input('region_list',brand_id);
	$("#brand_list_dialog dd ul.dialog-brandslist-s1").append('<li>'+text_append+'</li>');
}
function get_recommend_brand() {
    var brand_name = $.trim($('#recommend_brand_name').val());
	$("#show_brand_list").load('/admin/region/region_list?'+$.param({'region_name':brand_name }));
}
function del_brand(brand_id) {
	var obj = $("img[select_brand_id='"+brand_id+"']");
	obj.parent().parent().parent().remove();
}


</script>
</block>